Normalize feature names by removing invisible characters only - #1033
Merged
Conversation
Follow-up to #1027, which fixed invisible characters in UI feature names by transliterating names to ASCII. That approach silently renamed accented names (café became cafe, no longer matching code that checks :café) and rejected non-latin names entirely (新機能 normalized to empty). Instead, remove only invisible format/control characters (zero-width spaces, joiners, BOM, soft hyphens) and trim unicode whitespace, leaving all visible characters untouched. The normalization now lives in core as Flipper::Typecast.to_feature_name and is also applied to feature creation through the API, which had the same invisible character gap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1027 (thanks @koddsson for the report and fix!).
That PR fixed the real problem — pasting a feature name with an invisible character (zero-width space, word joiner, etc.) creates a flag that looks identical in the UI but never matches the name in code. However, transliterating to ASCII had two side effects:
caféin the UI produced acafeflag, which no longer matches code checkingFlipper.enabled?(:café)— the same mismatch bug the PR was fixing, just with visible characters.新機能(Japanese, Cyrillic, Hebrew, etc.) normalized to empty string and hit the invalid-name error, so those names could no longer be created via the UI at all.This changes the normalization to remove only what you can't see, leaving every visible character untouched:
\p{Cf}/\p{Cc}: zero-width spaces, joiners, BOM, soft hyphens)String#stripmisses)Since dropped characters are invisible, the result always matches what the user intended to type.
The logic now lives in core as
Flipper::Typecast.to_feature_nameso it can be shared, and is also applied toPOST /featuresin flipper-api, which had the same gap (with the same fallthrough: names that normalize to empty return the existing 422name_invaliderror instead of creating an empty-key feature).🤖 Generated with Claude Code